package com.lb.ai.common.response.code;

import com.lb.ai.common.response.IResultCode;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 用户模块响应码
 *
 * @author LiuB
 */
public class UserModule extends ResultCodeModule {
    
    public UserModule() {
        super(2, "用户模块");
    }
    
    @Getter
    @AllArgsConstructor
    public enum Code implements IResultCode {
        
        // 账户相关 1xx
        ACCOUNT_NOT_EXIST(101, "账号不存在"),
        ACCOUNT_ALREADY_EXIST(102, "账号已存在"),
        ACCOUNT_EXPIRED(103, "账号已过期"),
        ACCOUNT_DISABLED(104, "账号已禁用"),
        ACCOUNT_LOCKED(105, "账号已锁定"),
        
        // 认证相关 2xx
        PASSWORD_ERROR(201, "密码错误"),
        PASSWORD_EXPIRED(202, "密码已过期"),
        TOKEN_EXPIRED(203, "Token已过期"),
        TOKEN_INVALID(204, "Token无效"),
        
        // 授权相关 3xx
        NO_PERMISSION(301, "没有权限"),
        ROLE_NOT_EXIST(302, "角色不存在"),
        ROLE_DISABLED(303, "角色已禁用"),
        
        // 登录相关 4xx
        LOGIN_FAILED(401, "登录失败"),
        LOGOUT_FAILED(402, "登出失败"),
        ALREADY_LOGGED_IN(403, "已在其他设备登录");
        
        private final Integer code;
        private final String message;
        
        @Override
        public Integer getCode() {
            return new UserModule().generateCode(code);
        }
    }
    
    @Override
    public IResultCode[] getCodes() {
        return Code.values();
    }
} 